<blockquote class="layui-elem-quote">
  <div class="layui-inline">
    <i class="layui-icon layui-icon-list layui-head-icon"></i>
    <span class="layui-font-16 layui-font-green">拼团活动管理</span>
  </div>
  <div class="layui-pull-right">
    <a class="layui-btn layui-btn-primary layui-border-green" 
    href="{:url('/store/group/activity/create')}">添加拼团活动</a>
  </div>
</blockquote>
<div class="layui-card">
  <div class="layui-card-body">
    <fieldset class="layui-elem-field">
      <legend>条件搜索</legend>
      <div class="layui-field-box">
        <form class="layui-form layui-form-pane" action="{:url('/store/group/activity')}" method="GET">
          <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">活动时间</label>
              <div class="layui-inline" id="range-time">
                <div class="layui-input-inline">
                  <input type="text" autocomplete="off" name="start_time" id="strat-time" class="layui-input" placeholder="开始日期">
                </div>
                <div class="layui-form-mid">-</div>
                <div class="layui-input-inline">
                  <input type="text" autocomplete="off" name="end_time" id="end-time" class="layui-input" placeholder="结束日期">
                </div>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">活动状态</label>
                <div class="layui-input-inline">
                  <select name="status">
                    <option value="">请选择状态</option>
                    <option value="1">开启</option>
                    <option value="0">关闭</option>
                  </select>
                </div>
            </div>
              
            <div class="layui-inline">
              <label class="layui-form-label">活动名称</label>
              <div class="layui-input-inline">
                <input type="text" name="keyword"  placeholder="请输入活动名称" autocomplete="off" class="layui-input">
              </div> 
            </div>
            <div class="layui-inline">
              <div class="layui-input-inline">
                <button  class="layui-btn" lay-submit lay-filter="search">搜索</button>
              </div>
            </div>
          </div>
        </form>   
      </div>
    </fieldset>
    <form class="layui-form">
      <table class="layui-table">
        <thead>
          <tr>
          <th>ID</th>
          <th>活动名称</th>
          <th>活动封面</th>
          <th>可参与人数</th>
          <th>活动开始时间</th>
          <th>活动结束时间</th>
          <th>状态</th>
          <th>创建时间</th>
          <th>更新时间</th>
          <th>操作</th>
          </tr> 
        </thead>
      <tbody>
    
      {foreach $list as $vo}
      <tr>
        <td>{$vo.id}</td>
        <td>{$vo.activity_title}</td>
        <td><img src="{$vo.activity_cover}" class="layui-view-img"></td>
        <td>{empty name='vo.group_num'}不限制{else/}{$vo.group_num}{/empty}</td>
        <td>{$vo.start_time|date='Y-m-d H:i:s'}</td>
        <td>{$vo.end_time|date='Y-m-d H:i:s'}</td>
        <td>
            {empty name='$vo.status'}
              <span class="layui-font-red">关闭</span>
            {else/}  
              <span class="layui-font-green">开启</span>
            {/empty}
        </td>
        <td>{$vo.create_time}</td>
        <td>{$vo.update_time}</td>
        <td>
          <a class="layui-btn layui-btn-sm view-goods" data-id="{$vo.id}">查看活动商品</a>
          <a class="layui-btn layui-btn-sm" href="{:url('/store/group/activity/edit',['id'=> $vo.id])}">编辑</a>
          <a class="layui-btn layui-btn-sm layui-btn-danger del" data-url="{:url('/store/group/activity/delete',['id'=> $vo.id])}">删除</a>
        </td>
      </tr>
      {/foreach}
      </tbody>
      </table>
  </form>  
    {$list|raw}
  </div>
</div>
<script>  
    layui.use(['laydate'], function(){
      laydate = layui.laydate;
      laydate.render({
          elem: '#range-time',
          type: 'date',
          range: ['#strat-time', '#end-time'],
      });
      $('.view-goods').click(function(){
        let id = $(this).attr('data-id');
        layer.open({
          title: ['活动商品'],
          type:2,
          area: ['1000px','800px'],
          offset: '30px',
          maxmin:true,
          content: '/store/group/activity/goods?group_activity_id='+id,
        });

      });
    });              
</script>